package com.tanhua.server.interceptor;

import com.tanhua.model.db.User;

/**
 * threadlocal的工具了
 */
public class UserHolder {

    private static ThreadLocal<User> tl = new ThreadLocal();

    //存入threadloca
    public static void set(User user) {
        tl.set(user);
    }

    //从threadlocal取出User数据
    public static User getUser() {
        return tl.get();
    }

    //从threadlocal中取出用户id
    public static Long getUserId() {
        return tl.get().getId();
    }

    //从threadlocal中取出用户手机号
    public static String getMobile() {
        return tl.get().getMobile();
    }

    //删除threalocal中的数据
    public static void remove() {
        tl.remove();
    }
}
